package com.zrx.zrxaiagent.app;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ComputerApp {
    private final ChatClient chatClient;

    private static final String SYSTEM_PROMPT = "你是一位专业的电脑硬件配置专家。请根据用户需求推荐合适的电脑配置方案，包括CPU、显卡、内存、存储等硬件选择，提供性价比最优的配置建议，并解答相关技术问题。";
    public ComputerApp(ChatModel dashscopeChatModel) {
        // 初始化基于内存的对话记忆
        ChatMemory chatMemory = new InMemoryChatMemory();
        chatClient = ChatClient.builder(dashscopeChatModel)
                .defaultSystem(SYSTEM_PROMPT)
                .defaultAdvisors(
                        new MessageChatMemoryAdvisor(chatMemory)
                )
                .build();
    }
}
